import host from "./host";
export function sendApply(data, files) {
    return new Promise(function (resolve, reject) {
        var token = api.getPrefs({
			sync: true,
			key: 'token'
		});
        api.ajax({
            method: 'post',
            url: host.hostUrl + '/customer/saveapply',
            // timeout: 10,
            headers: {
                "authorization": 'Bearer ' + token
            },
            data: {
                values: data,
                files: files
            }
        }, function (ret, err) {
            if (err) {
                reject(err)
            } else {
                resolve(ret);
            }
        })
    });
}

export function customerList(data) {
    var token = api.getPrefs({
        sync: true,
        key: 'token'
    });
    return new Promise(function (resolve, reject) {
        api.ajax({
            method: 'get',
            url: host.hostUrl + '/customer/list',
            // timeout: 10,
            headers: {
                "authorization": 'Bearer ' + token
            },
            data: {
                values: data
            }
        }, function (ret, err) {
            if (err) {
                reject(err)
            } else {
                resolve(ret);
            }
        })
    });
}

export function applyinfo(id){
    var token = api.getPrefs({
        sync: true,
        key: 'token'
    });
    return new Promise(function (resolve, reject) {
        api.ajax({
            method: 'get',
            url: host.hostUrl + '/customer/applyinfo',
            // timeout: 10,
            headers: {
                "authorization": 'Bearer ' + token
            },
            data: {
                values: { id: id }
            }
        }, function (ret, err) {
            if (err) {
                reject(err)
            } else {
                resolve(ret);
            }
        })
    });
}

export function customerinfo(data) {
    var token = api.getPrefs({
        sync: true,
        key: 'token'
    });
    return new Promise(function (resolve, reject) {
        api.ajax({
            method: 'get',
            url: host.hostUrl + '/customer/info',
            // timeout: 10,
            headers: {
                "authorization": 'Bearer ' + token
            },
            data: {
                values: { id: data }
            }
        }, function (ret, err) {
            if (err) {
                reject(err)
            } else {
                resolve(ret);
            }
        })
    });
}